package com.yima.baseproj.module.tmpl;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yima.baseproj.module.tmpl.model.AppTmplAddParamModel;
import com.yima.baseproj.module.config.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;

@Data
@TableName("app_tmpl")
public class AppTmplEntity extends BaseEntity {

  @ApiModelProperty(value = "名称")
  @TableField(value = "name")
  private String name;

  @ApiModelProperty(value = "年龄")
  @TableField(value = "age")
  private Integer age;

  @ApiModelProperty(value = "是否是vip")
  @TableField(value = "is_vip")
  private Boolean isVip;

  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  @ApiModelProperty(value = "生日")
  @TableField(value = "birthday")
  private Date birthday;

  @ApiModelProperty(value = "状态。1:正常；0:异常")
  @TableField(value = "state")
  private Integer state;

  public void setData(AppTmplAddParamModel paramModel){
    this.name = paramModel.getName();
    this.age = paramModel.getAge();
    this.isVip = paramModel.getIsVip();
    this.birthday = paramModel.getBirthday();
    this.state = Integer.valueOf(paramModel.getState());
  }
}